{include file="public/layout" /}
{include file="gzh/header" /}
<body class="bodystyle" style="overflow-y: scroll; cursor: default; -moz-user-select: inherit;">
<div id="append_parent"></div>
<div id="ajaxwaitid"></div>
{include file="canal/left" /}
<div class="page min-hg-c-10" style="min-width:auto;margin-left:100px;">
    <div class="fixed-bar">
        <div class="item-title">
            <a class="back_xin" href="{:url('Gzh/index')}" title="返回"><i class="iconfont e-fanhui"></i></a>
            <a class="back_sz mt10" href="javascript:void(0);" onclick="click_to_eyou_1575506523('https://www.eyoucms.com/plus/view.php?aid=10970&origin_eycms=1', '微信公众号配置指南');"><i class="ui_tips"></i>使用教程</a>
            <div class="subject">
                <h3>公众号设置</h3>
                <h5></h5>
            </div>
        </div>
    </div>
    <form class="form-horizontal" id="post_form" action=" {:url('Gzh/config')}" method="post">
        <div class="ncap-form-default">
            {notempty name='$ipTips'}
            <dl class="row">
                <dt class="tit">
                    <label for="url" style="color: red;">注意事项</label>
                </dt>
                <dd class="opt">
                    {$ipTips}
                    <span class="err"></span>
                    <p class=""></p>
                </dd>
            </dl>
            {/notempty}
            {notempty name="$field.weixin"}
            <!-- 保存信息后显示 开始 -->
            <dl class="row">
                <dt class="tit">
                    <label for="url">服务器地址(URL)</label>
                </dt>
                <dd class="opt">
                    {$field.apiurl}
                    <a href="javascript:void(0);" onclick="showtext('apiurl');" class="ncap-btn ncap-btn-green apiurl" data-clipboard-text="{$field.apiurl}">复制URL</a>
                    <span class="err"></span>
                    <p class="">请登录微信公众平台-【开发】-【基本配置】 - 写入服务器地址(URL)</p>
                </dd>
            </dl>
            <dl class="row">
                <dt class="tit">
                    <label for="url"><em>*</em>令牌(Token)</label>
                </dt>
                <dd class="opt">
                    <input type="text" name="data[w_token]" placeholder="" value="{$field.w_token|default=''}" id="w_token" class="input-txt">
                    <span class="err"></span>
                    <p class="notic">请登录微信公众平台-【开发】-【基本配置】</p>
                </dd>
            </dl>
            {/notempty}
            <!-- 保存信息后显示 结束 -->
            <dl class="row">
                <dt class="tit">
                    <label for="title"><em>*</em>公众号名称</label>
                </dt>
                <dd class="opt">
                    <input type="text" name="data[wxname]" value="{$field.wxname|default=''}" id="wxname" class="input-txt">
                    <span class="err"></span>
                    <p class="notic">请登录微信公众平台查看</p>
                </dd>
            </dl>
            <dl class="row">
                <dt class="tit">
                    <label for="title">公众号二维码</label>
                </dt>
                <dd class="opt">
                    <div class="dan-pane">
                        <div class="images_upload images_upload_html" style="display:inline-block;">
                            <a href="javascript:void(0);" onclick="GetUploadify(1, '', 'allimg', 'img_call_back_pc');" class="img-upload no-float" title="点击上传">
                                <div class="y-line" id="web_logo_local_y_line" {notempty name="$field.logo"} style="display: none;" {/notempty}></div>
                                <div class="x-line" id="web_logo_local_x_line" {notempty name="$field.logo"} style="display: none;" {/notempty}></div>
                                <img src="{$field.logo}" id="web_logo_local_src" class="pic_con" {empty name="$field.logo"} style="display: none;" {/empty}>
                            </a>
                            <a href="javascript:void(0)" onclick="clear_pic('web_logo_local', 'web_logo_local_src', 'web_logo_local_y_line', 'web_logo_local_x_line')" class="delect" title="删除"></a>
                            <input type="hidden" id="web_logo_local" name="data[logo]" value="{$field.logo|default=''}">
                        </div>
                        <script type="text/javascript">
                            function img_call_back_pc(fileurl_tmp) {
                                $('#web_logo_local_y_line, #web_logo_local_x_line').hide();
                                $('#web_logo_local_src').show().attr('src', fileurl_tmp);
                                $('#web_logo_local').val(fileurl_tmp);
                            }
                            function clear_pic(id_0, id_1, id_2, id_3) {
                                $('#' + id_0).val('');
                                $('#' + id_1).hide().attr('src', '');
                                $('#' + id_2 + ', #' + id_3).show();
                            }
                        </script>
                    </div>
                </dd>
            </dl>
            <dl class="row">
                <dt class="tit">
                    <label for="title"><em>*</em>微信号</label>
                </dt>
                <dd class="opt">
                    <input type="text" name="data[weixin]" value="{$field.weixin|default=''}" id="weixin" class="input-txt">
                    <span class="err"></span>
                    <p class="notic">请登录微信公众平台查看</p>
                </dd>
            </dl>
            <dl class="row">
                <dt class="tit">
                    <label for="title"><em>*</em>开发者ID(AppID)</label>
                </dt>
                <dd class="opt">
                    <input type="text" name="data[appid]" value="{$field.appid|default=''}" id="appid" class="input-txt">
                    <span class="err"></span>
                    <p class="notic">请登录微信公众平台-【开发】-【基本配置】</p>
                </dd>
            </dl>
            <dl class="row">
                <dt class="tit">
                    <label for="title"><em>*</em>开发者密码(AppSecret)</label>
                </dt>
                <dd class="opt">
                    <input type="text" name="data[appsecret]" value="{$field.appsecret|default=''}" id="appsecret" class="input-txt">
                    <span class="err"></span>
                    <p class="notic">请登录微信公众平台-【开发】-【基本配置】</p>
                </dd>
            </dl>
            <!-- 保存信息后显示 开始 -->
            {notempty name="$field.weixin"}
            <dl class="row">
                <dt class="tit">
                    <label for="title">微信号类型</label>
                </dt>
                <dd class="opt"> 
                    {if condition="in_array($field.type, [2,4])"}
                        <font color="green">已认证</font>
                    {else /}
                        <font color="red">未认证</font>（大部分功能无法使用）
                    {/if}
                    <span class="err"></span>
                    <p class="notic"></p>
                </dd>
            </dl>
            {/notempty}
            <!-- 保存信息后显示 结束 -->
            <div class="bot">
                <input type="hidden" name="_ajax" value="1">
                <a href="JavaScript:void(0);" onclick="formSubmit();" class="ncap-btn-big ncap-btn-green" id="submitBtn">保存</a>
            </div>
        </div>
    </form>
</div>
<script type="text/javascript">

    $(document).ready(function(){
        
        $("#post_form").validate({
            debug: false, //调试模式取消submit的默认提交功能   
            focusInvalid: false, //当为false时，验证无效时，没有焦点响应  
            onkeyup: false,   
            submitHandler: function(form){   //表单提交句柄,为一回调函数，带一个参数：form 
                layer_loading('正在处理');  
                form.submit();   //提交表单   
            },  
            ignore:":button",   //不验证的元素
            rules:{
                w_token:{
                    required:true
                },
                wxname:{
                    required:true
                },
                weixin:{
                    required:true
                },
                appid:{
                    required:true
                },
                appsecret:{
                    required:true
                },
                type:{
                    required:true
                }
            },
            messages:{
                w_token:{
                    required:"请填写token"
                },
                wxname:{
                    required:"请填写公众号名称"
                },
                weixin:{
                    required:"请填写微信号"
                },
                appid:{
                    required:"请填写appid"
                },
                appsecret:{
                    required:"请填写AppSecret"
                },
                type:{
                    required:"请选择类型"
                }
            }
        });
    });

    // 判断输入框是否为空
    function formSubmit(){
        var url = " {:url('Gzh/config')}";
        $.ajax({
            type: 'POST',
            url: url,
            data: $("#post_form").serialize(),
            dataType: 'json',
            success: function(res) {
                if (res.code == 1) {
                    layer.msg(res.msg, {icon: 1, time:1000}, function(){
                        window.location.reload();
                    });
                } else {
                    layer.msg(res.msg, {icon: 5}, function(){
                        window.location.reload();
                    });
                }
            },
            error:function (e) {
                // showErrorAlert(e.responseText);
            }
        });
    }

</script>
<script type="text/javascript" src="__SKIN__/js/clipboard.min.js"></script>
<script type="text/javascript">
    function showtext(classname){
        var clipboard1 = new Clipboard("."+classname);clipboard1.on("success", function(e) {layer.msg("复制成功");});clipboard1.on("error", function(e) {layer.msg("复制失败！请手动复制", {icon:2});}); 
    }
</script>
{include file="public/footer" /}